<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Package Detail</title>

    </head>
    <body>
        <?php
        include('inc/init.php');
        include('inc/directconn.php');
        include('inc/queryhelper.php');


        $smarty->assign('title', $title);

        $id = -1;
        if (isset($_GET['id']))
            $id = $_GET['id'];

        $destid = -1;
        if (isset($_GET['destid']))
            $destid = $_GET['destid'];

        $smarty->template_dir = 'templates';


        //get embassy id from package detail
        $embassyid = getFieldValue('ats_package', 'tr_embassyid', 'id', $id);
        echo $embassyid;
        
        //get embassy data using smarty
        $embassy = $db->prepare("select * from ats_embassy where id='" . $embassyid . "'");
        $embassy->setFetchMode(PDO::FETCH_ASSOC);
        $embassy->execute();


        $dest = $db->prepare("select * from ats_destination");
        $dest->setFetchMode(PDO::FETCH_LAZY);
        $dest->execute();

        $package = $db->prepare("select * from ats_package where id='" . $id . "'");
        $package->setFetchMode(PDO::FETCH_ASSOC);
        $package->execute();

        $seldest = $db->prepare("select * from ats_destination where id='" . $destid . "'");
        $seldest->setFetchMode(PDO::FETCH_LAZY);
        $seldest->execute();

        $itinerary = $db->prepare("select * from ats_itinerary where packageid='" . $id . "' order by orderseq");
        $itinerary->setFetchMode(PDO::FETCH_LAZY);
        $itinerary->execute();

        //get types & prices
//        $prices = $db->prepare("select * from ats_packageprices where packageid='" . $id . "'");
//        $prices->setFetchMode(PDO::FETCH_ASSOC);
//        $prices->execute();
        //get images
        $images = $db->prepare("select * from ats_package_images where packageid='" . $id . "'");
        $images->setFetchMode(PDO::FETCH_ASSOC);
        $images->execute();

        //get city
        $cities = $db->prepare("select * from ats_city order by city");
        $cities->setFetchMode(PDO::FETCH_ASSOC);
        $cities->execute();


        $city = $db->prepare("select * from ats_city order by city");
        $city->execute();
        $city->setFetchMode(PDO::FETCH_ASSOC);
        $allcities = $city->fetchAll();
        $smarty->assign('allcities', $allcities);

        //get partners
        $partners = $db->prepare("select id,partnername from ats_partners order by partnername");
        $partners->setFetchMode(PDO::FETCH_ASSOC);
        $partners->execute();
        
        //get package categories
        $packcat = $db->prepare("select id,package from ats_package_category");
        $packcat->setFetchMode(PDO::FETCH_ASSOC);
        $packcat->execute();

        $smarty->assign('dest', $dest);
        $smarty->assign('seldest', $seldest);
        $smarty->assign('dest', $dest);
        $smarty->assign('package', $package);
        $smarty->assign('itinerary', $itinerary);
        $smarty->assign('catid', $id);
//        $smarty->assign('prices', $prices);
        $smarty->assign('images', $images);
        $smarty->assign('cities', $cities);
        $smarty->assign('partners', $partners);
        $smarty->assign('embassy', $embassy);
        $smarty->assign('packcat', $packcat);

        $smarty->display('packagedetail.tpl');
        ?>

    </body>
</html>